package org.youchan.aco;

import java.util.prefs.Preferences;

public class AcoPreferences  {
	public enum Key {
		TWITTER_ID("twitter_id"),
		TWITTER_PASSWORD("twitter_password");
		
		private String mName;
		
		private Key(String name) {
			mName = name;
		}
		
		public String toString() {
			return mName;
		}
	}
	
	private static AcoPreferences self_;
	private Preferences mPreferences;
	
	private AcoPreferences() {
		mPreferences = Preferences.systemNodeForPackage(AcoMain.class);
	}
	
	public static AcoPreferences getInstance() {
		if (self_ == null) {
			self_ = new AcoPreferences();
		}
		
		return self_;
	}
	
	public void set(Key key, String value) {
		mPreferences.put(key.toString(), value);
	}
	
	public String get(Key key) {
		return mPreferences.get(key.toString(), null);
	}
	
	public String get(Key key, String def) {
		return mPreferences.get(key.toString(), def);
	}
}
